<!--
*- coding = utf-8 -*-
#@Time : 2023/6/19 17:19
#@Author : 管茂良
#@File : index.vue
#@web  : www.php-china.com
#@Software: WebStorm
-->
<template>
  <div class="app-container">
      <TopNav :title="'首页'" :topOpacity="topOpacity">
          <template #leftIcon>
              <SvgIcon @click="handleToDiscover" :size="'15'" :iconClass="'left'" />
          </template>
          <template #rightIcon>
              <SvgIcon @click="handleToDiscover" :size="'15'" :iconClass="'right'" />
<!--              <SvgIcon @click="handleSendMoment" :size="'15'" :iconClass="'camera'" />-->
          </template>
      </TopNav>
      <u-button type="primary">随机寻找</u-button>
      <u-button type="primary">高级寻找</u-button>
<!--    <u-swipe-action :show="item.show" :index="index"-->
<!--                    v-for="(item, index) in list" :key="item.id"-->
<!--                    @click="handleClick" @open="handleOpen"-->
<!--                    :options="options"-->
<!--                    btn-width="180">-->
<!--      <view class="item u-border-bottom u-f u-f-ajs" @click="handleToChatInfo(item)">-->
<!--        <view class="u-f">-->
<!--          <view class="u-f u-f-ac u-f-ajc margin-right-10" style="width: 100rpx;height:100%;border-radius: 50%;overflow: hidden">-->
<!--            <u-image style="width:100%;height:100rpx" :src="item.images" />-->
<!--          </view>-->
<!--          <view class="">-->
<!--            <view class="name">-->
<!--              {{ item.title }}-->
<!--            </view>-->
<!--            <view class="content text-l">-->
<!--              {{ item.content }}-->
<!--            </view>-->
<!--          </view>-->
<!--        </view>-->
<!--        <view class="time text-l">-->
<!--          {{item.time}}-->
<!--        </view>-->
<!--      </view>-->
<!--    </u-swipe-action>-->
  </div>
</template>

<script setup lang="ts">
import {onMounted, ref} from "vue";
import {handleGetCurInstance, handlePageTo} from "@/utils/utils";
import TopNav from "@/components/topNav/index"

let topOpacity = ref(0.8)
let list = ref([
  {
    id: 1,
    uid: 1,
    title: '11111',
    content: '长安回望绣成堆，山顶千门次第开，一骑红尘妃子笑，无人知是荔枝来',
    images: 'https://cdn.uviewui.com/uview/common/logo.png',
    time: '11111222222211',
    show: false
  },
  {
    id: 2,
    uid: 2,
    title: '22222',
    content: 'contentconte望绣成堆，山顶千门次第开，一骑红尘妃子笑，无人ntcontentcontent',
    images: 'https://cdn.uviewui.com/uview/common/logo.png',
    time: '1111111',
    show: false
  },
  {
    id: 3,
    uid: 3,
    title: '333333333',
    content: '3333333333333望绣成堆，山顶千门次第开，一骑红尘妃子笑，无人3333333333',
    images: 'https://cdn.uviewui.com/uview/common/logo.png',
    time: '1111111',
    show: false,
  }
])
let options = ref( [
  {
    text: '删除',
    style: {
      backgroundColor: '#dd524d'
    }
  }
])
//跳转到聊天页
const handleToChatInfo = (val:any)=>{
  let {id} = val;
  handlePageTo("navigateTo","/pageChats/chatPage/index?id="+id)
}
const handleClick = (index: number, optionIndex: number)=> {
  if(optionIndex == 0) {
    uni.showModal({
      title:"你确定要删除？",
      success:()=>{
        console.log(3333);
        list.value.splice(index, 1);
      }
    })
  }
}

// 如果打开一个的时候，不需要关闭其他，则无需实现本方法
const handleOpen = (index: number) => {
  console.log(index);return;
  // 先将正在被操作的swipeAction标记为打开状态，否则由于props的特性限制，
  // 原本为'false'，再次设置为'false'会无效
  list.value[index].show = true;
  list.value.map((val, idx) => {
    if(index != idx) list.value[idx].show = false;
  })
}
//返回瞬间页面
const handleToDiscover = ()=>{
    handlePageTo("switchTab","/pageDiscover/index")
}

//发布瞬间
const handleSendMoment = ()=>{
    handlePageTo("switchTab","/pageDiscover/moments/sendMoments/index")
}
onMounted(()=>{

})
</script>
<style scoped lang="less">
.name{
  font-size:30rpx;
  font-weight: bold;
  line-height: 76rpx;
}
.content{
  font-size:22rpx;
  line-height:50rpx;
  max-width:400rpx;
}
.time{
  float:left;
  line-height:70rpx;
  font-size:24rpx;
  width:100rpx;
}
</style>

<style scoped lang="scss">
.item {
  display: flex;
  padding: 20rpx 20rpx;
}
</style>
